function [Kinematics_package_trials] = kinematics_package_each_trial(kinematics_each_trial,len,subject,task,eva,fes)

subject_num = strcat('s',subject);
[~,temp] = find(strcmp(fes,subject));
[~,temp1] = size(temp);
if temp1 == 0
    group = 'sham';
else
    group = 'fes';
end
for i = 1:1:len 
%    R2(i,1)  = kinematics_each_trial(i).vel_gaussian_R2;
    
    Kinematics_package_trials(i).subject = subject_num{1,1};
    Kinematics_package_trials(i).group = group;
    Kinematics_package_trials(i).eva = eva{1,1};
    
    Kinematics_package_trials(i).task = lower(task{1,1});
    if (i < 10)
        Kinematics_package_trials(i).trial_num = ['trial0',mat2str(i)];
    else
        Kinematics_package_trials(i).trial_num = ['trial',mat2str(i)];
    end
       
    Kinematics_package_trials(i).pkvel = kinematics_each_trial(i).pkvel;
    %Kinematics_package_trials(i).R_Gaussian = kinematics_each_trial(i).R_Gaussian;
    Kinematics_package_trials(i).bell_RMSe = kinematics_each_trial(i).bell_RMSe;
    Kinematics_package_trials(i).bell_dtw = kinematics_each_trial(i).bell_dtw;
    Kinematics_package_trials(i).duration = kinematics_each_trial(i).duration_time;
    Kinematics_package_trials(i).shoulder_angle =  kinematics_each_trial(i).shoulder_flextion_angle;
    Kinematics_package_trials(i).elbow_angle = kinematics_each_trial(i).elbow_flexion_angle;
end

% calculate endpoint variability
% x_mean = mean(hand_endpoint_x(:,1));
% y_mean = mean(hand_endpoint_y(:,1));
% hand_endpoint = sqrt((hand_endpoint_x - x_mean).^2 + (hand_endpoint_y - y_mean).^2);
% trial_num = 1;
% for i = counter:1:(len+counter-1)
%     Kinematics_package_trials(i).endpoint = hand_endpoint(i,1);
%     trial_num = trial_num+1;
% end

end

